/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "变量类JIT函数.h"

#include <matXX.h>
#include <随机数.h>
#include <线性代数/几何计算.h>



union U_返回数据集合 {
	Mat44f m_矩阵;
};





//=========================================== vec2 ========================================================
#define DEF_VEC2_ALLOC_参数 int64 num, bool 是否随机, int32 随机种子, vec2 范围
static void* f_JIT_Fun_vec2_alloc(DEF_VEC2_ALLOC_参数) {
	if (num < 0) num = 0;
	auto* v = new std::vector<vec2>(num);
	if (是否随机) {
		f_随机向量(*v, num, 范围, 随机种子, {1,1});
	}
	return v;
}

static void f_JIT_Fun_vec2_free(void* data) {
	delete data;
}

#define DEF_VEC2_resize_参数 void* val, uint64 num
static void f_JIT_Fun_vec2_resize(DEF_VEC2_resize_参数) {
	auto& v = *((std::vector<vec2>*)val);
	v.resize(num);
}

#define DEF_VEC2_SIZE_参数 const void* var
static int64 f_JIT_Fun_vec2_size(DEF_VEC2_SIZE_参数) {
	auto size = (*((const std::vector<vec2>*)var)).size();
	return size;
}

#define DEF_VEC2_push_back_参数 const void* var, vec2& v2_s
static void f_JIT_Fun_vec2_push_back(DEF_VEC2_push_back_参数) {
	(*((std::vector<vec2>*)var)).push_back(v2_s);
}

#define DEF_VEC2_insert_参数 const void* var, void* v2_s
static void f_JIT_Fun_vec2_insert(DEF_VEC2_insert_参数) {
	auto temp = (*((std::vector<vec2>*)v2_s));
	(*((std::vector<vec2>*)var)).insert((*((std::vector<vec2>*)var)).end(), temp.begin(), temp.end());
}

#define DEF_VEC2_erase_参数 const void* var, uint32 offset
static void f_JIT_Fun_vec2_erase(DEF_VEC2_erase_参数) {
	if (offset < (*((std::vector<vec2>*)var)).size()) {
		(*((std::vector<vec2>*)var)).erase((*((std::vector<vec2>*)var)).begin() + offset);
	}
}

#define DEF_VEC2_pop_back_参数 const void* var
static void f_JIT_Fun_vec2_pop_back(DEF_VEC2_pop_back_参数) {
	(*((std::vector<vec2>*)var)).pop_back();
}






//=============================================== vec3 =========================================================

vec3 f_JIT_Fun_vec3_随机(int32 种子, const vec2& x, const vec2& y, const vec2& z) {
	std::uniform_real_distribution<float32> disX(DEF_Min(x.x, x.y), DEF_Max(x.x, x.y));
	std::uniform_real_distribution<float32> disY(DEF_Min(y.x, y.y), DEF_Max(y.x, y.y));
	std::uniform_real_distribution<float32> disZ(DEF_Min(z.x, z.y), DEF_Max(z.x, z.y));
	std::default_random_engine e(种子);

	return vec3{ disX(e), disY(e), disZ(e) };
}


ivec3 f_JIT_Fun_ivec3_随机(int32 种子, const ivec2& x, const ivec2& y, const ivec2& z) {
	std::uniform_int_distribution<int32> disX(DEF_Min(x.x, x.y), DEF_Max(x.x, x.y));
	std::uniform_int_distribution<int32> disY(DEF_Min(y.x, y.y), DEF_Max(y.x, y.y));
	std::uniform_int_distribution<int32> disZ(DEF_Min(z.x, z.y), DEF_Max(z.x, z.y));
	std::default_random_engine e(种子);

	return ivec3{ disX(e), disY(e), disZ(e) };
}




void* f_JIT_Fun_vec3_alloc(DEF_VEC3_ALLOC_参数) {
	if (num < 0) num = 0;
	auto* v = new std::vector<vec3>(num);
	if (是否随机) {
		f_随机向量(*v, num, x, y, z, 随机种子);
	}
	return v;
}

static void f_JIT_Fun_vec3_free(void* data) {
	delete data;
}

#define DEF_VEC3_RESIZE_参数 void* val, uint64 num
static void f_JIT_Fun_vec3_resize(DEF_VEC3_RESIZE_参数) {
	auto& v = *((std::vector<vec3>*)val);
	v.resize(num);
}

#define DEF_VEC3_push_back_参数 void* val, const vec3& s
static void (f_JIT_Fun_vec3_push_back)(DEF_VEC3_push_back_参数) {
	(*((std::vector<vec3>*)val)).push_back(s);
}

static void (f_JIT_Fun_vec3_插入)(void* val, uint64 begin, void* s) {
	(*((std::vector<vec3>*)val)).insert((*((std::vector<vec3>*)val)).begin(), (*((std::vector<vec3>*)s)).begin(), (*((std::vector<vec3>*)s)).end());
}


int64 f_JIT_Fun_vec3_size(DEF_VEC3_SIZE_参数) {
	auto size = (*((const std::vector<vec3>*)var)).size();
	return size;
}

vec3* f_JIT_Fun_vec3_data(DEF_VEC3_SIZE_参数) {
	return (*((std::vector<vec3>*)var)).data();
}
/*
S_Mat44Array* f_JIT_Fun_mat_构建移动矩阵(S_Vec3Array* 向量) {
	vec3* v = 向量->ptr_userData;
	uint32 num = 向量->count;

	S_Mat44Array* r = (S_Mat44Array*)f_core_array_new(num, sizeof(Mat44f));
	auto* 输出矩阵 = r->ptr_userData;

	for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建移动矩阵(v[i]);
	
	return r;
}

S_Mat44Array* f_JIT_Fun_mat_构建缩放矩阵(S_Vec3Array* 向量) {
	vec3* v = 向量->ptr_userData;
	uint32 num = 向量->count;

	S_Mat44Array* r = (S_Mat44Array*)f_core_array_new(num, sizeof(Mat44f));
	auto* 输出矩阵 = r->ptr_userData;

	for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建缩放矩阵(v[i]);
	
	return r;
}

S_Mat44Array* f_JIT_Fun_mat_构建旋转矩阵(S_Vec3Array* 向量, S_F32Array* 角度) {
	vec3* v = 向量->ptr_userData;
	float32* angle = 角度->ptr_userData;
	uint32 num = 向量->count;
	uint32 num2 = 角度->count;

	S_Mat44Array* r = (S_Mat44Array*)f_core_array_new(num, sizeof(Mat44f));
	auto* 输出矩阵 = r->ptr_userData;

	bool 单例 = false;
	if (num2 < num) {
		单例 = true;
	}
	for (uint32 i = 0; i < num; ++i) {
		float32 角度;
		if (单例) {
			角度 = angle[0];
		}
		else {
			角度 = angle[i];
		}
		输出矩阵[i] = f_mat44_构建行式旋转矩阵(v[i], 角度);
	}
	
	return r;
}
*/

S_Mat44Array* f_JIT_Fun_mat_构建矩阵(S_Vec3Array* 向量, S_F32Array* 角度, uint8 矩阵类型) {
	vec3* v = 向量->ptr_userData;
	float32* angle = 角度->ptr_userData;
	uint32 num = 向量->count;
	uint32 num2 = 角度->count;

	S_Mat44Array* r = (S_Mat44Array*)f_core_array_new(num, sizeof(Mat44f));
	auto* 输出矩阵 = r->ptr_userData;

	switch (矩阵类型) {
	case 0: for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建移动矩阵(v[i]); break;
	case 1: for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建缩放矩阵(v[i]); break;
	case 2: {
		bool 单例 = false;
		if (num2 < num) {
			单例 = true;
		}
		for (uint32 i = 0; i < num; ++i) {
			float32 角度;
			if (单例) {
				角度 = angle[0];
			}
			else {
				角度 = angle[i];
			}
			输出矩阵[i] = f_mat44_构建行式旋转矩阵(v[i], 角度);
		}
		break;
	}
	}
	return r;
}


#define DEF_构建矩阵_v3_f_参数 vec3& 方向, float32 长度, uint8 矩阵类型
static Mat44f f_JIT_Fun_构建矩阵_v3f(DEF_构建矩阵_v3_f_参数) {
	Mat44f r;
	switch (矩阵类型) {
	case 0: r = f_mat44_构建移动矩阵(方向); break;
	case 1: r = f_mat44_构建缩放矩阵(方向); break;
	case 2: r = f_mat44_构建行式旋转矩阵(方向, 长度); break;
	case 3: r = f_mat44_构建行式旋转矩阵(方向, 长度); break;
	default:
		r = f_mat44_identity();
	}
	return r;
}
#define DEF_构建矩阵_v3s_f_参数 const void* 方向, float32 长度, uint8 矩阵类型
static void* f_JIT_Fun_构建矩阵_v3sf(DEF_构建矩阵_v3s_f_参数) {
	vec3* v = ((std::vector<vec3>*)方向)->data();
	uint32 num = ((std::vector<vec3>*)方向)->size();

	auto r = new std::vector<Mat44f>(num);
	auto* 输出矩阵 = r->data();
	switch (矩阵类型) {
	case 0: for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建移动矩阵(v[0]); break;
	case 1: for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建缩放矩阵(v[0]); break;
	case 2: for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建行式旋转矩阵(v[i], 长度); break;
	}
	return r;
}
#define DEF_构建矩阵_v3_fs_参数 const vec3& 方向, const void* 长度, uint8 矩阵类型
static void* f_JIT_Fun_构建矩阵_v3fs(DEF_构建矩阵_v3_fs_参数) {
	float32* angle = ((std::vector<float32>*)长度)->data();
	uint32 num = ((std::vector<float32>*)长度)->size();

	auto r = new std::vector<Mat44f>(num);
	auto* 输出矩阵 = r->data();
	switch (矩阵类型) {
	case 0: for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建移动矩阵(方向); break;
	case 1: for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建缩放矩阵(方向); break;
	case 2: for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建行式旋转矩阵(方向, angle[i]); break;
	}
	return r;
}
/*#define DEF_构建矩阵_v3s_fs_参数 const void* 方向, const void* 长度, uint8 矩阵类型
static void* f_JIT_Fun_构建矩阵_v3sfs(DEF_构建矩阵_v3s_fs_参数) {
	vec3* v = ((std::vector<vec3>*)方向)->data();
	float32* angle = ((std::vector<float32>*)长度)->data();
	uint32 num = ((std::vector<vec3>*)方向)->size();
	uint32 num2 = ((std::vector<float32>*)方向)->size();

	auto r = new std::vector<Mat44f>(num);
	auto* 输出矩阵 = r->data();
	switch (矩阵类型) {
	case 0: for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建移动矩阵(v[i]); break;
	case 1: for (uint32 i = 0; i < num; ++i) 输出矩阵[i] = f_mat44_构建缩放矩阵(v[i]); break;
	case 2: {
		bool 单例 = false;
		if (num2 < num) {
			单例 = true;
		}
		for (uint32 i = 0; i < num; ++i) {
			float32 角度;
			if (单例) {
				角度 = angle[0];
			}
			else {
				角度 = angle[i];
			}
			输出矩阵[i] = f_mat44_构建行式旋转矩阵(v[i], 角度);
		}
		break;
	}
	}
	return r;
}*/



//============================================= 矩阵 ========================================================
static void* f_JIT_Fun_Mat44_alloc(uint32 num) {
	auto* v = new std::vector<Mat44f>(num);
	return v;
}
static void f_JIT_Fun_Mat44_free(void* data) {
	delete data;
}






void f_vec3_合并(S_Vec3Array* 向量, float32* x, float32* y, float32* z, uint32 size[3]) {
	uint32 num = size[0];
	if (num < size[1]) num = size[1];
	if (num < size[2]) num = size[2];

	f_core_array_resize((S_Array*)向量, num);
	vec3* r_ptr = 向量->ptr_userData;

	bool 单例 = size[0] < num;
	for (uint32 i = 0; i < num; ++i) {
		if(单例) r_ptr[i].x = x[0];
		else r_ptr[i].x = x[i];
	}

	单例 = size[1] < num;
	for (uint32 i = 0; i < num; ++i) {
		if (单例) r_ptr[i].y = y[0];
		else r_ptr[i].y = y[i];
	}

	单例 = size[2] < num;
	for (uint32 i = 0; i < num; ++i) {
		if (单例) r_ptr[i].z = z[0];
		else r_ptr[i].z = z[i];
	}
}

void f_JIT_ivec3_合并(S_iVec3Array* 向量, S_I32Array* x, S_I32Array* y, S_I32Array* z) {
	uint32 num = DEF_Max(DEF_Max(x->count, y->count), z->count);

	bool 多例x = x->count >= num;
	bool 多例y = y->count >= num;
	bool 多例z = z->count >= num;

	f_core_array_resize((S_Array*)向量, num);

	for (uint32 i = 0; i < num; ++i) {
		if(多例x) 向量->ptr_userData[i].x = x->ptr_userData[i];
		else 向量->ptr_userData[i].x = x->ptr_userData[0];

		if (多例y) 向量->ptr_userData[i].y = y->ptr_userData[i];
		else 向量->ptr_userData[i].y = y->ptr_userData[0];

		if (多例z) 向量->ptr_userData[i].z = z->ptr_userData[i];
		else 向量->ptr_userData[i].z = z->ptr_userData[0];
	}

}

void f_JIT_vec3_分离(S_F32Array* x, S_F32Array* y, S_F32Array* z, const S_Vec3Array* 向量) {
	uint32 num = 向量->count;

	f_core_array_resize((S_Array*)x, num);
	f_core_array_resize((S_Array*)y, num);
	f_core_array_resize((S_Array*)z, num);

	
	for (uint32 i = 0; i < num; ++i) {
		vec3 v = 向量->ptr_userData[i];

		x->ptr_userData[i] = v.x;
		y->ptr_userData[i] = v.y;
		z->ptr_userData[i] = v.z;
	}
}

void f_JIT_ivec3_分离(S_I32Array* x, S_I32Array* y, S_I32Array* z, const S_iVec3Array* 向量) {
	uint32 num = 向量->count;

	f_core_array_resize((S_Array*)x, num);
	f_core_array_resize((S_Array*)y, num);
	f_core_array_resize((S_Array*)z, num);


	for (uint32 i = 0; i < num; ++i) {
		ivec3 v = 向量->ptr_userData[i];

		x->ptr_userData[i] = v.x;
		y->ptr_userData[i] = v.y;
		z->ptr_userData[i] = v.z;
	}
}

void f_JIT_重置I8数组(S_I8Array* 数组, uint32 num, int32 随机方式, ivec2 范围, int32 种子) {
	f_core_array_change_elt_size((S_Array*)数组, sizeof(int8));
	f_core_array_resize((S_Array*)数组, num);
	//S_I8Array* a = (S_I8Array*)f_core_array_new(num, sizeof(int8));
	
	int32 minVal = DEF_Min(范围.x, 范围.y);
	int32 maxVal = DEF_Max(范围.x, 范围.y);

	switch (随机方式) {
		case 1: {
			f_random_I8Array(数组, num, minVal, maxVal, 种子);
			break;
		}
		case 2: {
			float32 步进 = (maxVal - minVal) / num;
			for (uint32 i = 0; i < num; ++i) {
				数组->ptr_userData[i] = 步进 * i;
			}
			break;
		}
		default: {
			//std::cout<<t<<" : "<<a<<std::endl;
			for (uint32 i = 0; i < num; ++i) {
				数组->ptr_userData[i] = 0;
			}
		}
	}
}

void f_JIT_创建F32数组(S_F32Array* a, uint32 num, int32 随机方式, vec2 范围, int32 种子) {
	//S_F32Array* a = (S_F32Array*)f_core_array_new(num, sizeof(float32));
	f_core_array_resize((S_Array*)a, num);
	
	float32 minVal = DEF_Min(范围.x, 范围.y);
	float32 maxVal = DEF_Max(范围.x, 范围.y);
	
	switch (随机方式) {
	case 1: {
		f_random_F32Array(a, num, minVal, maxVal, 种子);
		break;
	}
	case 2: {
		float32 步进 = (maxVal - minVal) / DEF_Max(int32(num)-1, 1);
		for (uint32 i = 0; i < num; ++i) {
			a->ptr_userData[i] = 步进 * i;
		}
		break;
	}
	default: {
		//std::cout<<t<<" : "<<a<<std::endl;
		for (uint32 i = 0; i < num; ++i) {
			a->ptr_userData[i] = 种子;
		}
	}
	}
}

void f_JIT_创建I32数组(S_I32Array* array, uint32 num, int32 随机方式, ivec2 范围, int32 种子) {
	//S_I32Array* a = (S_I32Array*)f_core_array_new(num, sizeof(int32));
	f_core_array_resize((S_Array*)array, num);
	float32 minVal = DEF_Min(范围.x, 范围.y);
	float32 maxVal = DEF_Max(范围.x, 范围.y);

	switch (随机方式) {
	case 1: {
		f_random_I32Array(array, num, minVal, maxVal, 种子);
		break;
	}
	case 2: {
		float32 步进 = (maxVal - minVal) / num;
		for (uint32 i = 0; i < num; ++i) {
			array->ptr_userData[i] = 步进 * i;
		}
		break;
	}
	case 3: {
		for (uint32 i = 0; i < num; ++i) {
			array->ptr_userData[i] = 种子 * i;
		}
		break;
	}
	default: {
		for (uint32 i = 0; i < num; ++i) {
			array->ptr_userData[i] = 种子;
		}
	}
	}
}

void f_JIT_创建UI32数组(S_UI32Array* array, uint32 num, int32 随机方式, ivec2 范围, int32 种子) {
	//S_I32Array* a = (S_I32Array*)f_core_array_new(num, sizeof(int32));
	f_core_array_resize((S_Array*)array, num);
	float32 minVal = DEF_Min(范围.x, 范围.y);
	float32 maxVal = DEF_Max(范围.x, 范围.y);

	switch (随机方式) {
		case 1: {
			f_random_UI32Array(array, num, minVal, maxVal, 种子);
			break;
		}
		case 2: {
			float32 步进 = (maxVal - minVal) / num;
			for (uint32 i = 0; i < num; ++i) {
				array->ptr_userData[i] = 步进 * i;
			}
			break;
		}
		case 3: {
			for (uint32 i = 0; i < num; ++i) {
				array->ptr_userData[i] = 种子 * i;
			}
			break;
		}
		default: {
			for (uint32 i = 0; i < num; ++i) {
				array->ptr_userData[i] = 种子;
			}
		}
	}
}

void f_JIT_Fun_Vec3Clamp(S_Vec3Array* 向量, S_Vec3Array* 向量小, S_Vec3Array* 向量大, S_Vec3Array* 结果) {
	uint32 num = 向量->count;

	num = DEF_Max(num, 向量小->count);
	num = DEF_Max(num, 向量大->count);
	f_core_array_resize((S_Array*)结果, num);

	bool 向量单例 = 向量->count < num;
	bool 钳制小端单例 = 向量小->count < num;
	bool 钳制大端单例 = 向量大->count < num;

	vec3* v0 = 向量->ptr_userData;
	vec3* v1 = 向量小->ptr_userData;
	vec3* v2 = 向量大->ptr_userData;
	for (uint32 i = 0; i < num; ++i) {
		结果->ptr_userData[i] = clamp(向量单例 ? v0[0] : v0[i], 钳制小端单例 ? v1[0] : v1[i], 钳制大端单例 ? v2[0] : v2[i]);
	}
}


void f_JIT_打乱数组(S_Array* 数组, int32 种子) {
	if(!数组 || 数组->count < 2) return;

	uint32 num = 数组->count - 1;
	//uint32* temIndex = (uint32*)malloc(num*sizeof(uint32));

	for (uint32 i = 0; i < num; ++i) {
		int32 index_s = 0;
		int32 index_e = 0;

		srand(种子 + 1 + i);
		index_s = rand() % 数组->count;
		srand(种子 + index_s + i + 1);
		index_e = rand() % 数组->count;
		if(index_s == index_e) continue;
		
		f_core_array_swap(数组, index_s, index_e);
	}
	
}

static U_返回数据集合 返回空{};

uint8* f_JIT_坐标取数组(S_Array* 数组, const ivec3& 坐标, const ivec3& 分辨率) {
	
	if (坐标.x < 0 || 坐标.x >= 分辨率.x) return (uint8*)&返回空;
	if (坐标.y < 0 || 坐标.y >= 分辨率.y) return (uint8*)&返回空;
	if (坐标.z < 0 || 坐标.z >= 分辨率.z) return (uint8*)&返回空;


	uint32 层 = 分辨率.y * 分辨率.z;
	uint32 index = 层 * 坐标.z + (分辨率.x * 坐标.y) + 坐标.x;
	if(index >= 数组->count) return (uint8*)&返回空;

	uint32 元素大小 = f_core_array_get_elt_size(数组);
	return (uint8*)&数组->ptr_userData[index* 元素大小];
}

void f_JIT_3X3邻接数据(const S_Array* 数组, const ivec3& 坐标, const ivec3& 分辨率, S_Array* 邻接数据, S_I8Array* 空) {
	uint32 元素大小 = f_core_array_get_elt_size(数组);
	f_core_array_resize(邻接数据, 27);
	f_core_array_resize((S_Array*)空, 27);

	uint32 数据数量钳制 = 数组->count;
	uint32 局部坐标索引 = 0;
	uint32 层 = 分辨率.y * 分辨率.z;
	for (int32 z = -1; z < 2; ++z) {
		for (int32 y = -1; y < 2; ++y) {
			for (int32 x = -1; x < 2; ++x) {
				ivec3 coord = 坐标 + ivec3{x, y, z};
				uint32 index = 层 * coord.z + (分辨率.x * coord.y) + coord.x;

				uint32 xyz = 局部坐标索引;
				++局部坐标索引;
				bool 范围内 = true;

				if (coord.x < 0 || coord.x >= 分辨率.x) 范围内 = false;
				if (coord.y < 0 || coord.y >= 分辨率.y) 范围内 = false;
				if (coord.z < 0 || coord.z >= 分辨率.z) 范围内 = false;

				if (范围内 && index < 数据数量钳制) {
					//f_core_array_push_back((S_Array*)邻接数据, &数组->ptr_userData[index * 元素大小]);
					memcpy(&邻接数据->ptr_userData[xyz * 元素大小], &数组->ptr_userData[index * 元素大小], 元素大小);
					空->ptr_userData[xyz] = 1;
				}
				else {
					空->ptr_userData[xyz] = 0;
					memcpy(&邻接数据->ptr_userData[xyz * 元素大小], &返回空, 1);
				}
				
			}
		}
	}
}

void f_node_所有变量类节点JIT初始化() {
	
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_new), "S_Array*", "uint64 num, uint32 elt_size, bool 多维", f_core_array_new);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_new_type), "S_Array*", "uint64 num, E_值类型 类型", f_core_array_new_type);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_free), "void", "S_Array* array", f_core_array_free);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_resize), "void", "S_Array* array, uint64 num", f_core_array_resize);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_erase), DEF_S(int8), "S_Array* array, uint32, uint32", f_core_array_erase);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_clear), DEF_S(void), "S_Array* array", f_core_array_clear);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_push_back), "void", "S_Array* array, const uint8* data", f_core_array_push_back);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_pop_back), DEF_S(void), "S_Array* array", f_core_array_pop_back);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_pop_front), DEF_S(void), "S_Array* array", f_core_array_pop_front);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_insert_elt), "void", "S_Array* array, uint64 index, const uint8* data", f_core_array_insert_elt);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_change_elt_size), "void", "S_Array* array, const uint32 size", f_core_array_change_elt_size);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_at), "uint8*", "S_Array* array, uint32 offset", f_core_array_at);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_get_elt_size), "uint32", "const S_Array* array", f_core_array_get_elt_size);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_from), DEF_S(S_Array*), "const S_Array* array", f_core_array_from);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_copy), "void", "S_Array* dst, const S_Array* scr", f_core_array_copy);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_assign), "void", "S_Array* dst, const S_Array* scr", f_core_array_assign);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_append), "void", "S_Array* dst, const S_Array* scr", f_core_array_append);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_insert), "void", "S_Array*, const S_Array*, uint64", f_core_array_insert);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_find), DEF_S(int32), "S_Array* , const uint8* ", f_core_array_find);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_shuffle), DEF_S(S_Array*), "S_Array* , const S_iVec2Array*, bool copy", f_core_array_shuffle);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_statistics), DEF_S(uint32), "S_Array* , uint8* ", f_core_array_statistics);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_swap), DEF_S(void), "S_Array* a, uint32 s, uint32 e", f_core_array_swap);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_array_extract), DEF_S(S_Array*), "S_Array*, const ivec2&, uint32, int32, bool copy", f_core_array_extract);

	f_代码构建_添加JIT初始化函数指针(DEF_S(f_core_index_sort), DEF_S(S_iVec2Array*), "S_I32Array*, bool", f_core_index_sort);


	
	//f_代码构建_添加JIT初始化函数指针(DEF_S(f_f32_array_alloc), "S_F32Array*", "", f_f32_array_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_f32_array_fromF32_alloc), "S_F32Array*", "float32 data", f_f32_array_fromF32_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_f32_array_fromI32_alloc), "S_F32Array*", "S_I32Array* data", f_f32_array_fromI32_alloc);

	f_代码构建_添加JIT初始化函数指针(DEF_S(f_vec2_array_fromV_alloc), DEF_S(S_Vec2Array*), "float32*", f_vec2_array_fromV_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_vec2_array_fromV3s_alloc), DEF_S(S_Vec2Array*), "S_Vec3Array*", f_vec2_array_fromV3s_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_vec3_array_alloc), DEF_S(S_Vec3Array*), "uint64", f_vec3_array_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_vec3_array_fromV3_alloc), DEF_S(S_Vec3Array*), "vec3", f_vec3_array_fromV3_alloc);

	f_代码构建_添加JIT初始化函数指针(DEF_S(f_vec3_array_fromV4_alloc), DEF_S(S_Vec3Array*), "vec4", f_vec3_array_fromV4_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_vec4_array_fromV3_alloc), DEF_S(S_Vec4Array*), "vec3", f_vec4_array_fromV3_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_vec4_array_fromV4_alloc), DEF_S(S_Vec4Array*), "vec4", f_vec4_array_fromV4_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_vec4_array_fromV3s_alloc), DEF_S(S_Vec4Array*), "S_Vec3Array*", f_vec4_array_fromV3s_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_Mat44_array_formMat44Array), DEF_S(Mat44f), "S_Mat44Array* mats", f_Mat44_array_formMat44Array);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_Mat44_array_fromMat44_alloc), DEF_S(S_Mat44Array*), "const Mat44f& data", f_Mat44_array_fromMat44_alloc);
	

	f_代码构建_添加JIT初始化函数指针(DEF_S(f_f32_array_步进), "void", "S_F32Array* a, const vec2& r", f_f32_array_步进);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_重置I8数组), DEF_S(void), "S_I8Array*, uint32, int32, ivec2, int32", f_JIT_重置I8数组);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_创建F32数组), DEF_S(void), "S_F32Array*, uint32, int32, vec2, int32", f_JIT_创建F32数组);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_创建I32数组), DEF_S(void), "S_I32Array*, uint32, int32, ivec2, int32", f_JIT_创建I32数组);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_创建UI32数组), DEF_S(void), "S_UI32Array*, uint32, int32, ivec2, int32", f_JIT_创建UI32数组);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec3_随机), DEF_S(vec3), DEF_S(DEF_vec3_随机_参数), f_JIT_Fun_vec3_随机);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_ivec3_随机), DEF_S(ivec3), "int32, const ivec2&, const ivec2&, const ivec2&", f_JIT_Fun_ivec3_随机);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_vec3_合并), "void", "S_Vec3Array* 向量, float32* x, float32* y, float32* z, uint32 size[3]", f_vec3_合并);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_ivec3_合并), DEF_S(void), "S_iVec3Array*, S_I32Array*, S_I32Array*, S_I32Array* z", f_JIT_ivec3_合并);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_vec3_分离), DEF_S(void), "S_F32Array*, S_F32Array*, S_F32Array*, const S_Vec3Array*", f_JIT_vec3_分离);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_ivec3_分离), DEF_S(void), "S_I32Array*, S_I32Array*, S_I32Array*, const S_iVec3Array*", f_JIT_ivec3_分离);


	
	
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec3_push_back), "void", DEF_S(DEF_VEC3_push_back_参数), f_JIT_Fun_vec3_push_back);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec3_resize), "void", DEF_S(DEF_VEC3_RESIZE_参数), f_JIT_Fun_vec3_resize);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec3_插入), "void", "void* val, uint64 begin, void* s", f_JIT_Fun_vec3_插入);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec3_size), "int64", DEF_S(DEF_VEC3_SIZE_参数), f_JIT_Fun_vec3_size);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec3_data), "vec3*", DEF_S(DEF_VEC3_SIZE_参数), f_JIT_Fun_vec3_data);

	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_Mat44_alloc), "void*", "uint32 num", f_JIT_Fun_Mat44_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_Mat44_free), "void", "void* data", f_JIT_Fun_Mat44_free);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_构建矩阵_v3f), "Mat44f", DEF_S(DEF_构建矩阵_v3_f_参数), f_JIT_Fun_构建矩阵_v3f);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_构建矩阵_v3sf), "void", DEF_S(DEF_构建矩阵_v3s_f_参数), f_JIT_Fun_构建矩阵_v3sf);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_构建矩阵_v3fs), "void", DEF_S(DEF_构建矩阵_v3_fs_参数), f_JIT_Fun_构建矩阵_v3fs);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_mat_构建矩阵), "S_Mat44Array*", "S_Vec3Array* 向量, S_F32Array* 角度, uint8 矩阵类型", f_JIT_Fun_mat_构建矩阵);


	f_代码构建_添加JIT初始化函数指针(DEF_S(f_random_I8), DEF_S(int8), "ivec2, int32", f_random_I8);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_random_I32), "int32", "ivec2 区间, int32 随机种子", f_random_I32);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_random_F32), "float32", "int32 随机种子, vec2 区间 ", f_random_F32);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_随机_向量), "vec2", "float32 最小范围, float32 最大范围, int32 种子", f_随机_向量);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_random_Vec3Array), "void", "S_Vec3Array*, uint64, vec2, vec2, vec2, int32", f_random_Vec3Array);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_random_iVec2Array), "void", "S_iVec2Array* vec, uint64 num, const ivec2&, const ivec2&, int32, uint8", f_random_iVec2Array);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_random_iVec3Array), "void", "S_iVec3Array* vec, uint64 num, const ivec3&, const ivec3&, int32", f_random_iVec3Array);

	f_代码构建_添加JIT初始化函数指针(DEF_S(f_graph_两向量夹角弧度_export), "float32", "const vec3& vec0, const vec3& vec1", f_graph_两向量夹角弧度_export);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_math_quat两向量), "vec4", "const vec3& vec0, const vec3& vec1", f_math_quat两向量);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_math_quat两向量m), "void", "const S_Vec3Array* dirA, const S_Vec3Array* dirB, S_Vec4Array* r", f_math_quat两向量m);



	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_Vec3Clamp), "void", "S_Vec3Array*, S_Vec3Array*, S_Vec3Array*, S_Vec3Array*", f_JIT_Fun_Vec3Clamp);



	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_打乱数组), DEF_S(void), "S_Array* 数组, int32 种子", f_JIT_打乱数组);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_坐标取数组), DEF_S(uint8*), "S_Array*, const ivec3&, const ivec3&", f_JIT_坐标取数组);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_3X3邻接数据), DEF_S(uint8), "const S_Array*, const ivec3&, const ivec3&, S_Array*, S_I8Array*", f_JIT_3X3邻接数据);


	f_代码构建_添加JIT初始化函数指针(DEF_S(f_prop_合并行字符串), DEF_S(void), "S_Props& 目标, const S_Props& 源", f_prop_合并行字符串);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_prop_行字符串转整数), DEF_S(int32), "const S_Props& prop", f_prop_行字符串转整数);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_prop_行字符串转小数), DEF_S(float32), "const S_Props& prop", f_prop_行字符串转小数);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_prop_整数转行字符串), DEF_S(void), "S_Props& prop, int32 value", f_prop_整数转行字符串);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_prop_小数转行字符串), DEF_S(void), "S_Props& prop, float32 value", f_prop_小数转行字符串);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_prop_alloc_LineStrProp), DEF_S(S_Props), " ", f_prop_alloc_LineStrProp);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_prop_Release), DEF_S(void), "S_Props& prop", f_prop_Release);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_prop_alloc_Str), DEF_S(S_属性*), "", f_prop_alloc_Str);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_prop_free_Str), DEF_S(void), "S_属性*", f_prop_free_Str);





	//=========================================== 废弃 ================================================
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_Mat44_array_fromMat44_alloc_过度函数), "S_Mat44Array*", "void* data", f_Mat44_array_fromMat44_alloc_过度函数);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_f32_array_过度函数_从CXX_alloc), "S_F32Array*", "", f_f32_array_过度函数_从CXX_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_vec3_array_过度函数_从CXX_alloc), "S_Vec3Array*", "", f_vec3_array_过度函数_从CXX_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_f32_array_随机), "void", "S_F32Array* a, const vec2& r, bool 覆盖", f_f32_array_随机);

	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec2_alloc), "void*", DEF_S(DEF_VEC2_ALLOC_参数), f_JIT_Fun_vec2_alloc);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec2_free), "void", "void* data", f_JIT_Fun_vec2_free);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec2_resize), "void", DEF_S(DEF_VEC3_RESIZE_参数), f_JIT_Fun_vec2_resize);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec2_size), "void", DEF_S(DEF_VEC2_SIZE_参数), f_JIT_Fun_vec2_size);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec2_push_back), "void", DEF_S(DEF_VEC2_push_back_参数), f_JIT_Fun_vec2_push_back);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec2_insert), "void", DEF_S(DEF_VEC2_insert_参数), f_JIT_Fun_vec2_insert);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec2_erase), "void", DEF_S(DEF_VEC2_erase_参数), f_JIT_Fun_vec2_erase);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec2_pop_back), "void", DEF_S(DEF_VEC2_pop_back_参数), f_JIT_Fun_vec2_pop_back);
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_Fun_vec3_alloc), "void*", DEF_S(DEF_VEC3_ALLOC_参数), f_JIT_Fun_vec3_alloc);
	


}



